import requests


class IHRMDeptAPI():

    # 添加部门
    @classmethod
    def add_dept(cls,token,body):
        url = 'http://ihrm2-test.itheima.net/api/company/department'
        header = {"Content-Type":"application/json","Authorization":token}
        resp = requests.post(url=url,headers=header,json=body)
        return resp

    # 查询部门
    @classmethod
    def query_dept(cls,dept_id,token):
        url = 'http://ihrm2-test.itheima.net//api/company/department/'+dept_id
        header = {"Authorization": token}
        resp = requests.get(url=url,headers=header)
        return resp

    # 修改部门
    @classmethod
    def modify_dept(cls,dept_id,token,body):
        url = 'http://ihrm2-test.itheima.net//api/company/department/'+dept_id
        header = {"Content-Type":"application/json","Authorization": token}
        resp = requests.put(url=url, headers=header,json=body)
        return resp

    # 删除部门
    @classmethod
    def delete_dept(cls, dept_id, token):
        url = 'http://ihrm2-test.itheima.net//api/company/department/'+dept_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp